Yes — the method show in the superclass Video
is inherited in the subclass Movie.
The class definition for Video has a constructor that
initializes the member data of Video objects.
The class Movie has a constructor that initializes the data of
Movie objects.
The constructor for class Movie looks like this:
// constructor
public Movie( String ttl, int lngth, String dir, String rtng )
{
super(ttl, lngth); // use the super class's constuctor
director = dir; rating = rtng; // initialize the members new to Movie
}
The statement super(ttl, lngth)
invokes a
constructor of the parent
to initialize some of the data.
There are two constructors in the parent.
The one that is invoked is the one that matches the argument list
in super(ttl, lngth).Movie has.
Note:
super()
must be the first statement
in the subclass's constructor.
Why is the statement that
invokes the parent's constructor called super()?